﻿using GWSoft.Framework.Core.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace GWSoft.Framework.WebSite.Models
{
    /// <summary>
    /// 用户账户表
    /// </summary>
    [Table(name:"SYS_User")]
    [Description("用户账户表描述")]
    public class UserInfo : IBaseModel<string>
    {
        /// <summary>
        /// 用户Id
        /// </summary>
        [Key]
        [Column("UserId")]
        [StringLength(maximumLength: 32)]
        [Description("用户Id")]
        public string Id { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [Required]
        [StringLength(maximumLength: 50)]
        public string UserName { get; set; }

        /// <summary>
        /// 登录名
        /// </summary>
        [Required]
        [StringLength(maximumLength: 32)]
        public string LoginName { get; set; }

        /// <summary>
        /// 登录密码
        /// </summary>
        [StringLength(maximumLength:32)]
        public string LoginPwd { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed)]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 用户状态
        /// </summary>
        [Column(name: "UserState", TypeName = "decimal")]
        public int UserState { get; set; }
        /// <summary>
        /// 地区编码
        /// </summary>
        [StringLength(maximumLength: 6)]
        public string AreaCode { get; set; }

        /// <summary>
        /// 机构Id
        /// </summary>
        [ForeignKey("OrgId")]
        [StringLength(maximumLength: 32)]
        public string OrgId { get; set; }
        
        /// <summary>
        /// 机构名称
        /// </summary>
        [NotMapped]
        public string OrgName { get; set; }

        /// <summary>
        /// 部门Id
        /// </summary>
        [ForeignKey("DepId")]
        [StringLength(maximumLength: 32)]
        public string DepId { get; set; }

        /// <summary>
        /// 部门名称
        /// </summary>
        [NotMapped]
        public string DepName { get; set; }

        /// <summary>
        /// 领导类型(0:非领导,1:第一负责人,2:第二负责人,3:第三负责人)
        /// </summary>
        [Column(name: "LeaderType", TypeName = "decimal")]
        public int LeaderType { get; set; }

        /// <summary>
        /// 最后一次登录时间
        /// </summary>
        public DateTime LastLoginTime { get; set; }

        /// <summary>
        /// 顺序号
        /// </summary>
        [Required]
        [Column(name: "OrderNo", TypeName = "decimal")]
        public int OrderNo { get; set; }
    }
}
